# -*- coding: utf-8 -*-

# Define your item pipelines here
#
# Don't forget to add your pipeline to the ITEM_PIPELINES setting
# See: https://docs.scrapy.org/en/latest/topics/item-pipeline.html

import pymysql

class SatPipeline(object):
	
	def open_spider(self,spider):
		self.connect=pymysql.connect(
			host='127.0.0.1',
			port='3306',
			user='',
			password='',
			database='',
			chaset='utf8')
		self.cursor=self.connect.cursor

    def close_spider(self,spider):
    	self.cursor.close()
    	self.connect.close()
    def process_item(self, item, spider):
    	sql = 'insert into userinfo(openid,testdate,subject,point) values(%s,%s,%s,%s);'
        self.cursor.execute(sql,item)
        self.connect.commit()
        return item
